package base.java8.time;

import java.time.Duration;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

/**
 * 表示秒/纳秒的时间间隔,适合处理较短的时间
 *
 * @author 王霄
 * @date 2021/9/11 23:44
 */
public class DurationDemo {
    public static void main(String[] args) {
        System.out.println(Duration.ofHours(3));
        //计算三个小时的秒数
        System.out.println(Duration.ofHours(3).getSeconds());

        //计算两个日期差了多少天
        System.out.println(ChronoUnit.DAYS.between(LocalDate.now(), LocalDate.now().plusDays(2)));
    }
}
